﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<VCC.CMS.ViewModels.MenuViewEditModel>" %>
<%@ Import Namespace="VCC.Lib.Helpers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Thêm mới menu
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <%if(ViewData["MessageInfo"]==null){ %>
    <% using (Html.BeginForm("Create", "Menu", FormMethod.Post, new { id = "adminForm" } )) {%>
        <%= Html.ValidationSummary(true) %>

        <fieldset>
            <legend>Thêm mới</legend>
			<font color="red">*</font> là trường bắt buộc phải nhập.
			<table class="admintable">
				<tbody>
				<tr>
					<td class="key">Chọn vị trí menu (<font color="red">*</font>)</td>
					<td><%=Html.DropDownListFor(m => m.Menu.TypeID , new SelectList(Model.MenuTypes,"ID","Name").ToList())%></td>
				</tr>
				<tr>
					<td class="key">Menu Cha (<font color="red">*</font>)</td>
					<td>
					    <%=Html.DropDownListFor(m => m.Menu.ParentID, new SelectList(Model.Menus, "ID", "Name").ToList(), "--Chọn Menu cha--")%>
					</td>
				</tr>
				<tr>
					<td class="key">Tên menu (<font color="red">*</font>)</td>
					<td>
						<%= Html.TextBoxFor(m=>m.Menu.Name, new { @class = "required", maxlength = 250 })%>
					</td>
				</tr>
				<tr>
					<td class="key">English Name (<font color="red">*</font>)</td>
					<td>
						<%= Html.TextBoxFor(m=>m.Menu.EnglishName, new { @class = "required", maxlength = 250 })%>
					</td>
				</tr>
				<tr>
					<td class="key">Tên viết tắt (<font color="red">*</font>)</td>
					<td>
					    
						<%= Html.TextBoxFor(m=>m.Menu.ShortName, new { @class = "required", maxlength = 250 })%>
						
					</td>
				</tr>
				<tr>
					<td class="key">Liên kết với danh mục (<font color="red">*</font>)</td>
					<td>
					    <%--<%=Html.RadioButton("AutoLink", true, new { @Checked = "Checked" })%>--%>
					    <%= Html.DropDownList("CategoryID", new SelectList(Model.Categories, "Text", "Text").ToList(), "--Chọn danh mục--")%>
						<%=Html.TextBoxFor(m => m.Menu.NavigateUrl, new { @class = "required" })%>
					</td>
				</tr>
				<tr>
					<td class="key">Thứ tự ưu tiên (<font color="red">*</font>)</td>
					<td>
						<%= Html.TextBoxFor(m=>m.Menu.Priority, new { @class = "required number"})%> Độ ưu tiên nhỏ sẽ được xuất hiện trước
					</td>
				</tr>
				<tr>
					<td class="key">Xuất bản</td>
					<td>
						<%=Html.RadioButtonFor(m => m.Menu.PubYN, true, new { @Checked = "Checked" })%>Publish
						<%=Html.RadioButtonFor(m => m.Menu.PubYN, false)%>Không Publish
					</td>
				</tr>
				<tr>
					<td class="key">Mô tả</td>
					<td>
						<%= Html.TextAreaFor(m=>m.Menu.Description, new { style="width: 300px; height: 50px" })%>
					</td>
				</tr>
				<tr>
					<td colspan="2" align="center"><input type="submit" value="Lưu" /><input type="reset" value="Làm lại" /></td>
				</tr></tbody>
			 </table>
        </fieldset>

    <% } %>
    <script type="text/javascript">
        $(document).ready(function() {
            $("#adminForm").validate();
            //-----------Au to created url link----//
            $('#CategoryID').change(function() {
                var data = $('#CategoryID').val();
                var url = '/Applications/GetFriendlyUrl/';
                $.ajax({
                    url: url,
                    type: 'POST',
                    data: { DataUrl: data },
                    success: function(html) {
                    $('#Menu_NavigateUrl').val("/" + html);
                    },
                    error: function(mes) {
                        return false;
                    }
                });
            });
        });
	</script>
<% } %>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="Toolbar" runat="server">
<%= Html.Toolbar("Quay lại", "/Menu", "back")%>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="Header" runat="server">
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="Message" runat="server">
<%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%>  
</asp:Content>
